<script type="module" src="main.js"></script>
package.json
{
// ...
"type": "module",
// ...
}
//Add type=module to your index.js script tag (not just the package script tag)
<script type="module" src="./index.js"></script>
{
...
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": true
}
}
<script src="../src/main.js"></script>